﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Brush = System.Windows.Media.Brush;
using Button = System.Windows.Controls.Button;
using ComboBox = System.Windows.Controls.ComboBox;
using Panel = System.Windows.Controls.Panel;
using RadioButton = System.Windows.Controls.RadioButton;

namespace PlaceOrder_Client.Controls
{
    [TemplatePart(Name = "PART_ComboBox", Type = typeof(System.Windows.Controls.ComboBox))]
    [TemplatePart(Name = "PART_PageInfo", Type = typeof(System.Windows.Controls.Panel))]
    [TemplatePart(Name = "btnPrePage", Type = typeof(System.Windows.Controls.Button))]
    [TemplatePart(Name = "btnNextPage", Type = typeof(System.Windows.Controls.Button))]
    [TemplatePart(Name = "btnNum", Type = typeof(System.Windows.Controls.RadioButton))]
    [TemplatePart(Name = "PagePanel", Type = typeof(System.Windows.Controls.Panel))]
    public class Pagination : System.Windows.Controls.Control
    {
        #region 添加的固有属性
        private string record = "条记录";
        public string Record { get { return record; } }



        public string ShowRecord
        {
            get { return (string)GetValue(ShowRecordProperty); }
            set { SetValue(ShowRecordProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ShowRecord.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ShowRecordProperty =
            DependencyProperty.Register("ShowRecord", typeof(string), typeof(Pagination), new PropertyMetadata());
        #endregion


        #region Fields

        private ComboBox _cbbPageDataCount = null;


        private Button btnPrePage = null;
        private Button btnNextPage = null;
        private RadioButton btnNum = null;
        private Panel panelPage = null;


        #endregion


        #region Dependency Properties

        /// <summary>
        /// 是否显示每页数据量选择控件
        /// </summary>
        public static readonly DependencyProperty IsShowPageDataCountSelectorProperty = DependencyProperty.Register("IsShowPageDataCountSelector", typeof(bool), typeof(Pagination),
            new PropertyMetadata(true, null));
        /// <summary>
        /// 可选择的每页显示的数据条数集合
        /// </summary>
        public static readonly DependencyProperty PageDataCountCollectionProperty = DependencyProperty.Register("PageDataCountCollection", typeof(ObservableCollection<string>), typeof(Pagination),
            new PropertyMetadata(new ObservableCollection<string> { "5", "10", "25", "All" }, null));
        /// <summary>
        /// 每页最多显示的数据条数
        /// </summary>
        public static readonly DependencyProperty PageDataCountProperty = DependencyProperty.Register("PageDataCount", typeof(int), typeof(Pagination),
            new PropertyMetadata(5, OnPageDataCountPropertyChanged));
        /// <summary>
        /// 当前显示的可供选择的分页号集合
        /// </summary>
        public static readonly DependencyProperty ShowingPageNumberCollectionProperty = DependencyProperty.Register("ShowingPageNumberCollection", typeof(ObservableCollection<int>), typeof(Pagination),
            new PropertyMetadata(null, null));
        /// <summary>
        /// 当前选择的页数
        /// </summary>
        public static readonly DependencyProperty CurrentPageNumberProperty = DependencyProperty.Register("CurrentPageNumber", typeof(int), typeof(Pagination),
            new PropertyMetadata(1, OnCurrentPageNumberChanged));
        /// <summary>
        /// 是否显示分页信息
        /// </summary>
        public static readonly DependencyProperty IsShowPageInfoProperty = DependencyProperty.Register("IsShowPageInfo", typeof(bool), typeof(Pagination),
            new PropertyMetadata(true, null));
        /// <summary>
        /// 总的数据量
        /// </summary>
        public static readonly DependencyProperty TotalDataCountProperty = DependencyProperty.Register("TotalDataCount", typeof(int), typeof(Pagination),
            new PropertyMetadata(0, OnTotalDataCountChanged));



        /// <summary>
        /// 当前页显示的数据条数
        /// </summary>
        public static readonly DependencyProperty CurrentPageDataCountProperty = DependencyProperty.Register("CurrentPageDataCount", typeof(int), typeof(Pagination),
            new PropertyMetadata(0, null));
        /// <summary>
        /// 总页数
        /// </summary>
        public static readonly DependencyProperty TotalPageCountProperty = DependencyProperty.Register("TotalPageCount", typeof(int), typeof(Pagination),
            new PropertyMetadata(1, OnTotalPageCountChanged));



        /// <summary>
        /// 当前显示页的数据起始编号
        /// </summary>
        public static readonly DependencyProperty ShowingPageDataStartNumberProperty = DependencyProperty.Register("ShowingPageDataStartNumber", typeof(int), typeof(Pagination),
            new PropertyMetadata(0, OnPageDataStartNumberChanged));



        /// <summary>
        /// 当前显示页的数据结束编号
        /// </summary>
        public static readonly DependencyProperty ShowingPageDataEndNumberProperty = DependencyProperty.Register("ShowingPageDataEndNumber", typeof(int), typeof(Pagination),
            new PropertyMetadata(0, OnPageDataEndNumberChanged));



        /// <summary>
        /// 显示的可选择页的最大数量
        /// </summary>
        public static readonly DependencyProperty MaxShownPageCountProperty = DependencyProperty.Register("MaxShownPageCount", typeof(int), typeof(Pagination),
            new PropertyMetadata(7, null));
        /// <summary>
        /// 选中的页码的背景色
        /// </summary>
        public static readonly DependencyProperty SelectedPageBackgroundProperty = DependencyProperty.Register("SelectedPageBackground", typeof(Brush), typeof(Pagination),
            new PropertyMetadata(new SolidColorBrush(Colors.Red), null));
        /// <summary>
        /// 未选择的页码的背景色
        /// </summary>
        public static readonly DependencyProperty PageSelectorBackgroundProperty = DependencyProperty.Register("PageSelectorBackground", typeof(Brush), typeof(Pagination),
            new PropertyMetadata(null, null));

        #endregion

        #region Property Wrappers

        public bool IsShowPageDataCountSelector
        {
            get { return (bool)GetValue(IsShowPageDataCountSelectorProperty); }
            set { SetValue(IsShowPageDataCountSelectorProperty, value); }
        }
        public ObservableCollection<string> PageDataCountCollection
        {
            get { return (ObservableCollection<string>)GetValue(PageDataCountCollectionProperty); }
            set { SetValue(PageDataCountCollectionProperty, value); }
        }
        public int PageDataCount
        {
            get { return (int)GetValue(PageDataCountProperty); }
            set { SetValue(PageDataCountProperty, value); }
        }
        public ObservableCollection<int> ShowingPageNumberCollection
        {
            get { return (ObservableCollection<int>)GetValue(ShowingPageNumberCollectionProperty); }
            set { SetValue(ShowingPageNumberCollectionProperty, value); }
        }
        public int CurrentPageNumber
        {
            get { return (int)GetValue(CurrentPageNumberProperty); }
            set { SetValue(CurrentPageNumberProperty, value); }
        }
        public bool IsShowPageInfo
        {
            get { return (bool)GetValue(IsShowPageInfoProperty); }
            set { SetValue(IsShowPageInfoProperty, value); }
        }
        public int TotalDataCount
        {
            get { return (int)GetValue(TotalDataCountProperty); }
            set { SetValue(TotalDataCountProperty, value); }
        }
        public int TotalPageCount
        {
            get { return (int)GetValue(TotalPageCountProperty); }
            set { SetValue(TotalPageCountProperty, value); }
        }
        public int ShowingPageDataStartNumber
        {
            get { return (int)GetValue(ShowingPageDataStartNumberProperty); }
            set { SetValue(ShowingPageDataStartNumberProperty, value); }
        }
        public int ShowingPageDataEndNumber
        {
            get { return (int)GetValue(ShowingPageDataEndNumberProperty); }
            set { SetValue(ShowingPageDataEndNumberProperty, value); }
        }
        public int MaxShownPageCount
        {
            get { return (int)GetValue(MaxShownPageCountProperty); }
            set { SetValue(MaxShownPageCountProperty, value); }
        }
        public Brush SelectedPageBackground
        {
            get { return (Brush)GetValue(SelectedPageBackgroundProperty); }
            set { SetValue(SelectedPageBackgroundProperty, value); }
        }
        public Brush PageSelectorBackground
        {
            get { return (Brush)GetValue(PageSelectorBackgroundProperty); }
            set { SetValue(PageSelectorBackgroundProperty, value); }
        }

        #endregion



        static Pagination()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(Pagination), new FrameworkPropertyMetadata(typeof(Pagination)));
        }



        #region Override Methods

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();


            //初始化控件
            InitControls();
            ShowingPageNumberCollection = new ObservableCollection<int>();
            PageCol = new ObservableCollection<PageControlItemModel>();
            //初始化数据

            InitData();
        }

        #endregion

        #region Property Changed Event Methods

        /// <summary>
        /// 当前选择的页数发生改变时的回调方法
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnCurrentPageNumberChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Pagination pagination = d as Pagination;
            if (pagination == null)
            {
                return;
            }
            foreach (var item in pagination.PageCol)
            {
                if (item.Page == pagination.CurrentPageNumber)
                    item.IsSelected = true;
            }


        }
        /// <summary>
        /// 总页数发生变化时回调方法
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnTotalPageCountChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Pagination pagination = d as Pagination;
            if (pagination == null)
            {
                return;
            }
            if (pagination.panelPage == null)
            {
                pagination.panelPage = pagination.GetTemplateChild("PagePanel") as Panel;
            }
            pagination.panelPage.Visibility = pagination.TotalPageCount == 1 ? Visibility.Hidden : Visibility.Visible;
        }
        /// <summary>
        /// 当总数发生变化时
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnTotalDataCountChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Pagination pagination = d as Pagination;
            if (pagination == null)
            {
                return;
            }
            if (pagination.btnNextPage == null)
            {
                return;
            }
            pagination.CalcPageNumList();
        }
        /// <summary>
        /// 当前显示页的数据起始编号回调方法
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnPageDataStartNumberChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Pagination pagination = d as Pagination;
            if (pagination == null)
            {
                return;
            }
            pagination.ShowRecord = string.Format("显示第{0}到第{1}条数据，总共{2}条数据，每页显示", pagination.ShowingPageDataStartNumber, pagination.ShowingPageDataEndNumber, pagination.TotalDataCount);
        }
        /// <summary>
        /// 当前显示页的数据结束编号回调方法
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnPageDataEndNumberChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Pagination pagination = d as Pagination;
            if (pagination == null)
            {
                return;
            }
            pagination.ShowRecord = string.Format("显示第{0}到第{1}条数据，总共{2}条数据，每页显示", pagination.ShowingPageDataStartNumber, pagination.ShowingPageDataEndNumber, pagination.TotalDataCount);
        }
        /// <summary>
        /// 每页显示的最大数据量发生改变时的回调方法
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        private static void OnPageDataCountPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Pagination pagination = d as Pagination;
            if (pagination == null)
            {
                return;
            }

            pagination.InitData();
        }

        #endregion


        private void _cbbPageDataCount_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox cbb = sender as ComboBox;
            if (cbb == null || cbb.SelectedItem == null)
            {
                return;
            }

            string selectedCountString = cbb.SelectedItem.ToString();
            if (!int.TryParse(selectedCountString, out int selectedDataCount))
            {
                PageDataCount = TotalDataCount;
                InitData();
                return;
            }

            PageDataCount = selectedDataCount;
            InitData();
        }

        #region Private Methods

        /// <summary>
        /// 初始化控件
        /// </summary>
        private void InitControls()
        {
            _cbbPageDataCount = GetTemplateChild("PART_ComboBox") as ComboBox;
            if (_cbbPageDataCount != null)
            {
                _cbbPageDataCount.SelectionChanged += _cbbPageDataCount_SelectionChanged;
            }

            if (panelPage == null)
            {
                panelPage = GetTemplateChild("PagePanel") as Panel;
                panelPage.Visibility = TotalPageCount == 1 ? Visibility.Hidden : Visibility.Visible;
            }
            btnPrePage = GetTemplateChild("btnPrePage") as Button;
            if (btnPrePage != null)
            {
                btnPrePage.Click += btnPrePage_Click;
            }
            btnNextPage = GetTemplateChild("btnNextPage") as Button;
            if (btnNextPage != null)
            {
                btnNextPage.Click += btnNextPage_Click;
            }
            btnNum = GetTemplateChild("btnNum") as RadioButton;
            if (btnNum != null)
            {

            }
        }
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void InitData()
        {
            if (PageDataCount > 0)
            {
                //根据总的数据量和每页最大显示的数据量计算总的页数
                if (TotalDataCount % PageDataCount > 0)
                {
                    TotalPageCount = TotalDataCount / PageDataCount + 1;
                }
                else
                {
                    TotalPageCount = TotalDataCount / PageDataCount;
                }

                CalcPageNumList();
                CurrentPageNumber = 1;
            }
        }
        /// <summary>
        /// 更新每页信息
        /// </summary>
        private void UpdateShowingPageInfo()
        {
            if (TotalDataCount == 0)
            {
                ShowingPageDataStartNumber = 0;
                ShowingPageDataEndNumber = 0;
            }
            else if (CurrentPageNumber < TotalPageCount)
            {
                ShowingPageDataStartNumber = (CurrentPageNumber - 1) * PageDataCount + 1;
                ShowingPageDataEndNumber = CurrentPageNumber * PageDataCount;
            }
            else if (CurrentPageNumber == TotalPageCount)
            {
                ShowingPageDataStartNumber = (CurrentPageNumber - 1) * PageDataCount + 1;
                ShowingPageDataEndNumber = TotalDataCount;
            }
            else //当前页删除完后，会出现大于情况
            {
                ShowingPageDataStartNumber = (CurrentPageNumber - 2) * PageDataCount + 1;
                ShowingPageDataEndNumber = (CurrentPageNumber - 1) * PageDataCount;
            }
            ShowRecord = string.Format("显示第{0}到第{1}条数据，总共{2}条数据，每页显示", ShowingPageDataStartNumber, ShowingPageDataEndNumber, TotalDataCount);
        }


        #endregion

        #region 修改页码选择  有省略号的

        private List<PageControlItemModel> _list = null;

        public ObservableCollection<PageControlItemModel> PageCol
        {
            get { return (ObservableCollection<PageControlItemModel>)GetValue(PageColProperty); }
            set { SetValue(PageColProperty, value); }
        }

        // Using a DependencyProperty as the backing store for PageCol.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty PageColProperty =
            DependencyProperty.Register("PageCol", typeof(ObservableCollection<PageControlItemModel>), typeof(Pagination), new PropertyMetadata());

        /// <summary>
        /// 右边显示的页码数量
        /// </summary>
        public int ContinuousCount
        {
            get { return (int)GetValue(ContinuousCountProperty); }
            set { SetValue(ContinuousCountProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ContinuousCount.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ContinuousCountProperty =
            DependencyProperty.Register("ContinuousCount", typeof(int), typeof(Pagination), new PropertyMetadata(5, OnContinuousCountChanged));

        private static void OnContinuousCountChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Pagination pagination = d as Pagination;
            if (pagination == null)
            {
                return;
            }
            pagination.CalcPageNumList();
        }


        /// <summary>
        /// 处理重新加载界面写的属性
        /// </summary>
        public bool IsResetProperty
        {
            get { return (bool)GetValue(IsResetPropertyProperty); }
            set { SetValue(IsResetPropertyProperty, value); }
        }

        // Using a DependencyProperty as the backing store for IsResetProperty.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty IsResetPropertyProperty =
            DependencyProperty.Register("IsResetProperty", typeof(bool), typeof(Pagination), new PropertyMetadata(false, OnIsResetPropertyChanged));

        private static void OnIsResetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Pagination pagination = d as Pagination;
            if (pagination == null)
            {
                return;
            }
            if (pagination.IsResetProperty)
            {

                pagination.CurrentPageNumber = 1;
                if (pagination._cbbPageDataCount != null)
                {
                    if (pagination._cbbPageDataCount.SelectedIndex == 0)
                    {
                        pagination._cbbPageDataCount.SelectedIndex = 1;
                    }
                    pagination._cbbPageDataCount.SelectedIndex = 0;
                }
            }
        }



        /// <summary>
        /// 单击页码事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNum_Click(PageControlItemModel itemModel)
        {

            if (itemModel.Page != CurrentPageNumber)
            {
                CurrentPageNumber = itemModel.Page;
                CalcPageNumList();

                PageChangedEventArgs args = new PageChangedEventArgs(itemModel.Page);
            }
        }
        /// <summary>
        /// 上一页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPrePage_Click(object sender, RoutedEventArgs e)
        {
            int prePage = CurrentPageNumber - 1;
            if (prePage < 1) prePage = 1;
            if (prePage != CurrentPageNumber)
            {
                CurrentPageNumber = prePage;
                CalcPageNumList();

                PageChangedEventArgs args = new PageChangedEventArgs(prePage);
                //PageChanged(sender, args);
            }
        }
        /// <summary>
        /// 下一页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNextPage_Click(object sender, RoutedEventArgs e)
        {
            int nextPage = CurrentPageNumber + 1;
            if (nextPage > TotalPageCount) nextPage = TotalPageCount;
            if (nextPage != CurrentPageNumber)
            {

                CurrentPageNumber = nextPage;
                CalcPageNumList();

                PageChangedEventArgs args = new PageChangedEventArgs(nextPage);
                //PageChanged(sender, args);
            }
        }
        /// <summary>
        /// 计算页码
        /// </summary>
        private void CalcPageNumList()
        {
            TotalPageCount = (TotalDataCount - 1) / PageDataCount + 1; //计算总页数PageCount
            UpdateShowingPageInfo();
            _list = new List<PageControlItemModel>();

            //第一页
            PageControlItemModel item = new PageControlItemModel(1, CurrentPageNumber, btnNum_Click);
            _list.Add(item);

            int itemCnt = 0;

            int _page = 1;

            itemCnt = ContinuousCount + CurrentPageNumber > TotalPageCount ? TotalPageCount : ContinuousCount + CurrentPageNumber;
            if (ContinuousCount + CurrentPageNumber > TotalPageCount)
            {
                _page = TotalPageCount - ContinuousCount > 0 ? TotalPageCount - ContinuousCount : 1;
            }
            else
            {
                _page = CurrentPageNumber;
            }
            for (int i = _page; i < itemCnt; i++)
            {

                item = new PageControlItemModel(i, CurrentPageNumber, btnNum_Click);

                if (!_list.Exists(a => a.Page == item.Page))
                {
                    _list.Add(item);
                }
            }



            //最后一页
            item = new PageControlItemModel(TotalPageCount, CurrentPageNumber, btnNum_Click);
            if (!_list.Exists(a => a.Page == item.Page))
            {
                _list.Add(item);
            }

            for (int i = _list.Count - 1; i > 0; i--)
            {
                if (_list[i].Page - _list[i - 1].Page > 1)
                {
                    _list.Insert(i, new PageControlItemModel(0, CurrentPageNumber, btnNum_Click, 2));
                }
            }

            //上一页下一页
            if (CurrentPageNumber == 1)
            {
                btnPrePage.IsEnabled = false;

            }
            else
            {
                btnPrePage.IsEnabled = true;

            }
            if (CurrentPageNumber == TotalPageCount)
            {
                btnNextPage.IsEnabled = false;

            }
            else
            {
                btnNextPage.IsEnabled = true;

            }

            PageCol.Clear();
            _list.ForEach(a => { PageCol.Add(a); });


        }

    }
    #endregion
    #region 分页控件Item Model
    /// <summary>
    /// 分页控件Item Model
    /// </summary>
    public class PageControlItemModel : INotifyPropertyChanged
    {
        public Action<PageControlItemModel> CurClickAction;

        private int _Type = 1;
        /// <summary>
        /// 类型(1数字 2省略号)
        /// </summary>
        public int Type
        {
            get { return _Type; }
            set
            {
                _Type = value;
                OnPropertyChanged("Type");

                if (_Type == 1)
                {
                    NumVisible = Visibility.Visible;
                    OmitVisible = Visibility.Collapsed;
                }
                else
                {
                    NumVisible = Visibility.Collapsed;
                    OmitVisible = Visibility.Visible;
                }
            }
        }

        private bool _IsSelected;
        /// <summary>
        /// 当前页码是否选中
        /// </summary>
        public bool IsSelected
        {
            get { return _IsSelected; }
            set
            {
                _IsSelected = value;
                OnPropertyChanged("IsSelected");
                if (value)
                {
                    CurClickAction?.Invoke(this);
                }
            }
        }

        private int _Page;
        /// <summary>
        /// 页码
        /// </summary>
        public int Page
        {
            get { return _Page; }
            set
            {
                _Page = value;
                OnPropertyChanged("Page");
            }
        }

        private Visibility _NumVisible = Visibility.Visible;
        /// <summary>
        /// 数字可见
        /// </summary>
        public Visibility NumVisible
        {
            get { return _NumVisible; }
            set
            {
                _NumVisible = value;
                OnPropertyChanged("NumVisible");
            }
        }

        private Visibility _OmitVisible = Visibility.Collapsed;
        /// <summary>
        /// 省略号可见
        /// </summary>
        public Visibility OmitVisible
        {
            get { return _OmitVisible; }
            set
            {
                _OmitVisible = value;
                OnPropertyChanged("OmitVisible");
            }
        }

        /// <summary>
        /// 分页控件Item Model
        /// </summary>
        /// <param name="page">页码</param>
        /// <param name="currentPage">当前页码</param>
        /// <param name="type">类型(1数字 2省略号)</param>
        public PageControlItemModel(int page, int currentPage, Action<PageControlItemModel> curClickAction, int type = 1)
        {
            Type = type;
            Page = page;
            CurClickAction = curClickAction;
            IsSelected = page == currentPage;
        }


        #region INotifyPropertyChanged接口
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string name)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }
        #endregion

    }
    #endregion
    #region 分页事件参数
    /// <summary>
    /// 分页事件参数
    /// </summary>
    public class PageChangedEventArgs : EventArgs
    {
        private int _Page = 1;
        /// <summary>
        /// 当前页码
        /// </summary>
        public int Page
        {
            get
            {
                return _Page;
            }
        }

        /// <summary>
        /// 分页事件参数
        /// </summary>
        /// <param name="page">当前页码</param>
        public PageChangedEventArgs(int page)
        {
            _Page = page;
        }
    }
    #endregion
}
